/*
 * @Author: your name
 * @Date: 2022-03-25 10:17:23
 * @LastEditTime: 2022-04-22 09:31:07
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \mallAdmin\src\app\main\recharge\order\recharge-order.pipe.ts
 */
import { Pipe, PipeTransform } from '@angular/core';

/**
 * 订单状态
 * 0-待付款、1-充值中、2-交易完成、3-支付超时、4-客户取消、5-客服取消、6-交易结束
 */
export const rechargeOrderStateArrs: any = [
  { id: 0, label: '待付款', color: '#417DE5' },
  { id: 1, label: '充值中', color: '#FF9D2A' },
  { id: 2, label: '交易完成', color: '#008000' },
  { id: 3, label: '支付超时', color: '#FF0000' },
  { id: 4, label: '客户取消', color: '#FF0000' },
  { id: 5, label: '客服取消', color: '#FF0000' },
  { id: 6, label: '交易结束', color: '#008000' },
  { id: 7, label: '充值失败', color: '#FF0000' }
];
@Pipe({
  name: 'rechargeOrderState'
})
export class RechargeOrderStatePipe implements PipeTransform {
  transform(value: any, key: string) {
    let tempObj: any = rechargeOrderStateArrs.find((item: any) => item.id === value);
    switch (key) {
      case 'label':
        return tempObj?.label || '-';
      case 'colour':
        return tempObj?.color || '#333333';
    }
  }
}

/**
 * 收款状态
 * 0未付款 1已付款 2部分退款 3全部退款
 */
export const collectionStatusArrs: any = [
  { id: 0, label: '未付款', color: '#417DE5' },
  { id: 1, label: '已付款', color: '#FF9D2A' },
  { id: 2, label: '部分退款', color: '#008000' },
  { id: 3, label: '全部退款', color: '#FF0000' }
];
@Pipe({
  name: 'collectionStatus'
})
export class CollectionStatusPipe implements PipeTransform {
  transform(value: any, key?: string) {
    let tempObj: any = collectionStatusArrs.find((item: any) => item.id === value);
    return tempObj?.label || '-';
  }
}

/**
 * 支付方式
 * 1：支付宝、2：微信、3：银联
 */
 export const payTypeArrs: any = [
  { id: 1, label: '支付宝', color: '#417DE5' },
  { id: 2, label: '微信', color: '#FF9D2A' },
  { id: 3, label: '银联', color: '#008000' },
  { id: 4, label: '爱豆', color: '#ffe58f' }
];
@Pipe({
  name: 'payTypeStatus'
})
export class PayTypeStatusPipe implements PipeTransform {
  transform(value: any, key?: string) {
    let tempObj: any = payTypeArrs.find((item: any) => item.id === value);
    return tempObj?.label || '-';
  }
}

